package com.authine.cloudpivot.ext.applicationservice;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSONObject;
import com.authine.cloudpivot.ext.constants.AppConst;
import com.authine.cloudpivot.ext.constants.ServiceUrlConst;
import com.authine.cloudpivot.ext.dto.OrderCustomerGoodsDto;
import com.authine.cloudpivot.ext.dto.OrderVendorDto;
import com.authine.cloudpivot.ext.utils.HttpClientUtil;
import com.authine.hermes.app.launcher.response.SingleResponse;
import com.authine.hermes.app.launcher.service.ApplicationService;
import com.authine.mvp.app.launcher.dto.bo.response.BOList;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.extern.slf4j.Slf4j;

import javax.ws.rs.POST;
import javax.ws.rs.Path;

import java.util.Map;

import static com.authine.hermes.app.launcher.service.ApplicationServiceFoundation.CUSTOM_SERVICE;


@Slf4j
@Path("ToAuditService")
public class ToAuditService extends ApplicationService {


    @Path("queryToAuditList")
    @POST
    @Operation(summary = "待审批",tags = CUSTOM_SERVICE)
    public SingleResponse queryToAuditList(@Parameter OrderVendorDto dto) {
        String url = HttpClientUtil.getUrl(AppConst.ORDER_CENTER, ServiceUrlConst.TO_AUDIT_URL);
        Map<String, Object> map = BeanUtil.beanToMap(dto);
        String execute = HttpClientUtil.execute(url, map);
        BOList boList = JSONObject.parseObject(execute, BOList.class);
        return  SingleResponse.of(boList.getData().get(0));
    }

}
